package org.equinoxosgi.toast.internal.dev.gps.fake;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

import org.equinoxosgi.toast.dev.gps.IGps;

public class FakeGps implements IGps {
	private final Random random = new Random();

	@Override
	public int getHeading() {
		return random.nextInt(360);
	}

	@Override
	public int getLatitude() {
		return -90000000 + random.nextInt(180000000);
	}

	@Override
	public int getLongitude() {
		return -180000000 + random.nextInt(360000000);
	}

	@Override
	public int getSpeed() {
		return random.nextInt(100);
	}

	@Override
	public String toString() {
		final StringBuilder sb = new StringBuilder();
		sb.append(new SimpleDateFormat("[yyyy-MM-dd HH:mm:ss]").format(new Date()));
		final float lon = getLongitude();
		sb.append(String.format(" lon=%.06f%s", Math.abs(lon) / 1000000, lon > 0 ? "[E]" : "[W]"));
		final float lat = getLatitude();
		sb.append(String.format(" lat=%.06f%s", Math.abs(lat) / 1000000, lat > 0 ? "[N]" : "[S]"));
		sb.append(String.format(" Heading=%d°", getHeading()));
		sb.append(String.format(" Speed=%dkm/h", getSpeed()));
		return sb.toString();
	}
}
